<?php

namespace App\Http\Controllers\admin;

use Illuminate\Http\Request;

use APP\Http\Requests;
use App\Http\Controllers\Controller;

use DB;
use Intervention\Image\ImageManagerStatic as Image;

class WebsiteController extends Controller
{
	 public function index()
    {

    	$list = DB::table('logo')->first();
    	return view('admin.name.Site',['list'=>$list]);
    }
    
      public function doUpload(Request $request)
      {
      	$id=$request->input('id');
      	$data = $request->except('_token');

      	if($request->hasFile('logo')){
    		$file = $request->file('logo');
    		if ($file->isValid()) {
			    //获取后缀
    			$ext = $file->getClientOriginalExtension();
    			$picname = time().rand(1000,9999).'.'.$ext;
    			$file->move('./admin/img',$picname);
    			if($file->getError()>0){
    				$data['logo']='';
    			}else{
    				$data['logo']='./admin/img/'.$picname;
    			}
    			
			}
    	}
    			
    			$row=DB::table('logo')->where('id',$id)->update($data);
    			if($row>0){
    				return redirect('admin/name');
    			}
    }
 }
